﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    public static class SceneManager
    {
        public static List<Scene> scenes = new List<Scene>();
        public static List<Scene> scenesToRemove = new List<Scene>();
        public static List<Scene> scenesToAdd = new List<Scene>();
        public static void update(int dTime)
        {
            foreach (Scene scene in scenes)
            {
                scene.update(dTime);
                scene.handleInput();
                if (scene.readyToExit)
                {
                    scenesToRemove.Add(scene);
                }
            }

            foreach (Scene scene in scenesToAdd)
            {
                scenes.Add(scene);
            }
            foreach (Scene scene in scenesToRemove)
            {
                scenes.Remove(scene);
            }
            scenesToAdd.Clear();
            scenesToRemove.Clear();
        }
        public static void draw(SpriteBatch sb)
        {
            foreach (Scene scene in scenes)
            {
                scene.draw(sb);
            }
        }
    }
}
